import React, { Component } from 'react';
import { Tabs, Badge } from 'antd-mobile';
import { CommonContainer } from './commonStyle';
import ComList from './commonList/comList'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'




const tabs = [
    { title: <Badge >全部评论</Badge> },
    { title: <Badge >只看作者</Badge> },
];
@withRouter
@connect(
    state => {
        return ({
            commonList: state.getIn(['detail', 'common']),
            detail2: state.getIn(['detail', 'detail'])

        })
    }
)
class common extends Component {

    // state = {
    //     commn: [{ "replyCount": "0", "floor": "1", "sonPosts": [{ "threadId": "13042301", "postId": "194490484", "repliedPid": "0", "rootPid": "0", "status": "128", "updateTime": "1596858847", "formatTime": "3分钟前", "message": "<p>沙发 没钱</p>", "messageArray": [{ "type": "text", "text": "沙发 没钱", "url": "", "userId": "" }], "supportCount": "0", "opposeCount": "0", "authorId": "3772605", "authorName": "qq7792723", "authorAvatar": "https://face.fengimg.com/avatar.php?uid=3772605", "authorLevel": "7", "authorLevelTitle": "白金苹果", "authorGroupIcon": "https://feng-bbs-att-1255531212.image.myqcloud.com/level/level_7.png", "isSupported": "no", "isSupportedFull": "no", "isOpposed": "no", "isOpposedFull": "no", "tail": "iPhone X", "repliedUserId": "", "repliedUserName": "", "repliedUserAvatar": "", "quoteContent": "", "quoteContentMessageArray": [], "replyCount": "0", "invisible": "0" }] }, { "replyCount": "0", "floor": "2", "sonPosts": [{ "threadId": "13042301", "postId": "194490488", "repliedPid": "0", "rootPid": "0", "status": "128", "updateTime": "1596858959", "formatTime": "2分钟前", "message": "三星除了贵，其他没毛病", "messageArray": [{ "type": "text", "text": "三星除了贵，其他没毛病", "url": "", "userId": "" }], "supportCount": "0", "opposeCount": "0", "authorId": "18201524", "authorName": "我才是追逐", "authorAvatar": "https://face.fengimg.com/avatar.php?uid=18201524", "authorLevel": "4", "authorLevelTitle": "红苹果", "authorGroupIcon": "https://feng-bbs-att-1255531212.image.myqcloud.com/level/level_4.png", "isSupported": "no", "isSupportedFull": "no", "isOpposed": "no", "isOpposedFull": "no", "tail": "威锋网页版", "repliedUserId": "", "repliedUserName": "", "repliedUserAvatar": "", "quoteContent": "", "quoteContentMessageArray": [], "replyCount": "0", "invisible": "0" }] }]
    // }
    // componentDidMount() {
    //     this.setState({
    //         commn:this.props.commonList.dataList
    //     })
    //     setTimeout(()=>{
    //         console.log('asdsadsadsds')
    //     },1000)
    // }
    render() {
        return (

            <CommonContainer>
                <Tabs tabs={tabs}
                    initialPage={0}
                >
                    <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', backgroundColor: '#fff', flexDirection: 'column' }}>
                        {
                            this.props.detail2 && this.props.commonList && this.props.commonList.dataList.map(item => {
                                return <ComList item={item} key={item.sonPosts[0].postId}></ComList>

                            })
                        }
                        {
                            this.props.commonList && this.props.commonList.dataList.length == 0 ?
                                <div style={
                                    {
                                        height: '1.5rem',
                                        lineHeight: '1.5rem'
                                    }
                                }>
                                    暂无评论
                            </div> : null
                        }


                    </div>
                    <div style={
                        {
                            height: '1.5rem',
                            lineHeight: '1.5rem',
                            // alignItems:"center"
                            textAlign: "center"
                        }
                    }>
                        暂无回复
                            </div> : null

                </Tabs>
            </CommonContainer>
        );
    }
}

export default common;